home *** CD-ROM | disk | FTP | other *** search
- TITLE_PG.TN - Thu 23 Nov 89 00:20 - Page 1:
-
-
-
-
-
-
-
-
-
-
-
-
-
- The MicroFirm Function Library
- for Microsoft C & Quick C
- ver 1.01
-
- Copyright 1988-89 by Robert B. Stout dba MicroFirm
- portions Copyright 1986-87 by Stephen E. Margison
- All rights reserved
-
-
-
-
-
- -------------------------------
- TECHNICAL NOTES ON RELEASE 1.01
- -------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TOC.TN - Thu 23 Nov 89 00:20 - Page 2:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The MicroFirm Funtion Library - Technical notes on release 1.01
-
-
- Page Topic
-
- 3 Object-oriented features of ver 1.01 - future C++ directions
- 4 High-level stream I/O
- 5 BASIC-like string functions
- 6 Julian (scalar) date functions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- OOPS.TXT - Thu 23 Nov 89 00:20 - Page 3:
-
- The MicroFirm Function Library includes several groups of functions
- which, not accidentally, lend themselves to an object-oriented view of
- programming. Future versions of The MicroFirm Function Library will, in
- fact, include C++ class implementations of some of these:
-
-
- Stream I/O
- ----------
-
- The high-level stream I/O functions and their associated installable
- stream filter functions are the most obvious candidates for conversion
- to classes. These are already written to hide the functional code and
- data structures as much as possible from the implementation.
-
-
- BASIC-like string handling
- --------------------------
-
- It seems everyone who does C++ classes includes a string class, so why
- should I be different? As such classes go, the functions in The
- MicroFirm Function Library are quite conservative, yet addresss the
- requirements of most programmers who are simply looking for the ease of
- BASIC-like string processing in C.
-
-
- Math
- ----
-
- The specialized math routines for performing CRC calculations, integer
- square roots, and simultaneous divide and modulus can all be coded in
- C++ so that separate versions need not be called for different data
- types as is the case with the C versions.
-
-
- Directory operations
- --------------------
-
- Although written for compatibility with BSD 4.3 the opendir(), readdir()
- and closedir() functions could well be treated as a C++ class.
-
-
- Filename processing
- -------------------
-
- The MicroFirm Function Library's extensive facilities for normalizing
- filenames, explicit smart wildcard matching, etc. could be enhanced by
- the implementation of a DOS filename class.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- STREAMIO.TXT - Thu 23 Nov 89 00:20 - Page 4:
-
- The MicroFirm Function Library's stream I/O is a unique (for now)
- approach to high-level file I/O. Analogous to a shell's (e.g. DOS's
- COMMAND.COM) ability to pipe and/or redirect file I/O, the stream I/O
- functions provide the ability to install filters in the stream. Examples
- included in the release of The MicroFirm Function Library include
- filters to force streams to either upper or lower case, to encrypt or
- decrypt streams, and to perform simple run-length encoding. Note that
- the use of these filters is totally transparent to the application.
-
- Another unique feature of The MicroFirm Function Library's stream I/O is
- the ability to treat external data channels (e.g. interrupt-driven
- serial I/O functions) as if they are simply another stream device like a
- disk file. In order for this to work, the minimum requirement is for
- appropriate functions to exist which function analogously to the normal
- fgetc() and fputc() functions. A function to unget a character may also
- be required (see below).
-
- Filters installed in streams are installed as if on a stack and invoked
- in a last installed, first called fashion. Only one filter may be
- installed which alters the number of characters transmitted to or from a
- stream. An example of such filters are the run-length encoding filters
- included in this library. These are not particularly useful as written
- (sorry - ran out of time to do LZHuff or arithmetic coding filters), but
- demonstrate how to write such filters. Since such filters must have the
- ability to gobble or source characters not in the original stream, they
- must be stacked immediately before or after the stream destination or
- source, respectively. This means such filters acting on a stream opened
- for writing must be installed first in the chain (last called). Such
- filters installed in a stream opened for reading must be installed last
- (first called). Note that, since character sinking or sourcing is done
- within such a filter, the character count reported by the sfread() and
- sfwrite() functions is the number of characters without such processing.
- For example, if I read in 1024 characters from a file then pass them
- through a compression filter to another file, sfwrite() will return 1024
- as the number of characters written even though the number of characters
- physically written was smaller due to the action of the compression
- filter. Similarly, if I read the compressed file back through an
- expansion filter, sfread() will report that I read 1024 character from a
- file which may have been physically smaller since it was compressed.
-
- There are two other requirements of filters which must have the ability
- alter the stream's character count. If such a stream is opened for
- reading, it must provide an unget-equivalent function to allow it to
- replace unused characters in the stream. If a stream is opened for
- writing, it must provide a flush function to force unprocessed output to
- the stream when the stream is closed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- BASTRNGS.TXT - Thu 23 Nov 89 00:20 - Page 5:
-
- The MicroFirm Function Library provides the unique ability for C
- programmers to process character arrays (strings) as simply as most
- BASIC programmers (or C++ programmers!) It does this by maintaining and
- reusing a pool of string space. Note that since these strings are
- reused, to retain permanent copies requires the use of strcpy() or
- strdup(). This is an inconvenience at times but avoids the overhead
- inherent in "garbage collection" algorithms such as used by BASIC. Most
- times, the strings will be used before their string space is reused.
-
- The primary function of this package is stralloc() which returns a
- string buffer from the pool which is guaranteed to be large enough to
- hold a string of the requested size. The stralloc() function is called
- internally by several of the other functions and is available for use by
- applications needing a temporary string storage buffer.
-
- The string pool defaults to 16 strings in small and compact models and
- 64 strings in large and medium models, with all strings dynamically
- resized as required. Where these are too few, the str_init() function
- allows up to 128 strings in small and compact model or up to 512 strings
- in large and medium model. To avoid possible problems when used by
- recursive functions or functions otherwise using malloc(), the size of
- the strings maintained may also be set to a constant via str_init(). The
- str_free() function frees the entire string pool.
-
- In addition to left(), right() and mid() corresponding to BASIC's LEFT$,
- RIGHT$, and MID$ functions, The MicroFirm Function Library adds the
- string_add() string concatenation function as an analogue of BASIC's
- "A$=A$+B$+C$" syntax.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- JULFUNCS.TXT - Thu 23 Nov 89 00:20 - Page 6:
-
- The Julian date conversion routines convert dates in standard year,
- month, and date formats to and from Julian dates. Note that these are
- not true Julian dates based on the Julian calendar, but are scalar
- numbers representing the number of days since Jan 1, 0001. As such they
- may be used for calculating the number of days between two dates, etc.
- Two additional functions are supplied for converting Julian date to day
- of the week and day of the year value. The first day of the week
- conversion function, julian_to_wkday(), returns the numerical day of the
- week, starting with Sunday equal to zero. The second day of the week
- conversion routine, julian_to_dayname() returns the name of the day as
- specified for the current locale - see setlocale() for more details. In
- addition to the basic Julian date routines, four symmetrical functions
- are provided to convert Julian dates from and to both time_t values
- and/or tm structures.
-
-
- EXAMPLE
-
- unsigned mo,day,yr;
- long jday1,jday2;
- jday1=ymd_to_julian(1903,1,3);
- jday2=ymd_to_julian(1974,6,9);
- printf("There were %ld days between 1/3/1903 and 6/9/1974\n",
- jday2-jday1);
- printf("6/9/74 (day # %d) was a %s\n",
- julian_to_yrday(jday2), julian_to_wkday(jday2));
- printf("That is %f years\n", (double)(jday2-jday1)/365.2425);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-